{include file="index/canvas_structure" /}

<!--目标用户浮窗-->
<div id="target_user_window" style="text-align:center;position:fixed;z-index:102;left: 40%;top: 30%;width: 185px;height:185px;border: 3px ridge;background-color: rgba(111,177,223,0.34);">

    <!--<a  href="javascript:if($('#changeTargetUser').css('display')=='none'){ $('#changeTargetUser').show();$('#changeUserSpan').html('点击收起');}else {$('#changeTargetUser').hide();$('#changeUserSpan').html('更改用户');}" class="edit" style="max-width: 100%;" title="更改">
        <span id="changeUserSpan" style="font-size: 15px;">更改用户</span></a>

    <!--更改目标用户后续
    <div class="" id="changeTargetUser" style="display:none;position:absolute;left: 100%;top: 5%;width: 80px;">
        <form method="post" onsubmit="return checkChangeTargetUser()" action="{:url('index/changeGonggantuUser')}">
            <input type="text" id="newTargetUser" name="newTargetUser" style="width: 100px;background-color: rgba(13,0,9,0.69);color:white;height: 25px;">
            <input type="hidden" name="toolId" value="{$toolId}"/>
            <button type="submit" class="button button-highlight button-rounded button-small" style="color:black;background-color:#ff9046;font-size: 10px;margin-top: 8px;">确定</button>
        </form>
    </div>-->


    <div style="margin-top: 15px;">
        <img id="targetUserImg" src="__IMG__/target_user_icon.png" style="width: 117px;height: 117px;">
    </div>
    <div>目标用户：<br>
        <text style="color: red;">*</text>

        <div class="tooltip">
            <input oninput="
                var data = new Object();
                data.toolId = '{$toolId}';
                data.info =$(this).val();
                data.type = 'changeTargetUser';
                ws.send(JSON.stringify(data));"
                   id="newTargetUser" value="{$targetUser}" maxlength="100" placeholder="在此输入目标用户" onmouseover="$(this).css('border-bottom','1px solid black')" onmouseout="$(this).css('border-bottom','2px solid transparent')" style="background:inherit;border: none;border-bottom: 2px solid transparent;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width: 170px;"/>

            <div class="tooltiptext" style="width: 150px;">修改目标用户</div>
        </div>

    </div>



    <div id="next_step_btn" onclick="gonggantu_next_step();" class="button button-action button-medium " style="padding: 0;width: 100%;position:absolute;left: 0%;top: 110%;">
            填好了，下一步
    </div>


</div>


<script>
    function gonggantu_next_step(){

        var newTargetUser = $('#newTargetUser').val();
        var toolId = '{$toolId}';

        var re = new RegExp("^[ ]+$");
        if (!re.test(newTargetUser) && newTargetUser != "" && newTargetUser != null) {

                $.ajax({
                    type: "POST",
                    url: "__PUBLIC__/index/index/changeGonggantuUser",
                    data: {
                        toolId: toolId,
                        newTargetUser: newTargetUser
                    },
                    success: function (result) {
                        //console.log(result);
                        //window.location.reload();

                        $('#target_user_window').animate({left:"1%"});


                        setTimeout(function () {
                            window.location.reload();
                        },1000);
                    }
                });
        }else{
            toastr.error('目标用户不能为空或空格！');
            setTimeout(function () {
                toastr.clear();
            }, 4000);
        }


    }
</script>
